﻿/*
Copyright (c) 2011 Vratislav Cermak (vratacermak@gmail.com)
 
This file is part of TeachMe Project. See http://code.google.com/p/teach-me for more information.
 
TeachMe is an open source project. Using of TeachMe is free of charge.
It is distributed under GNU General Public License version 3 (GPLv3).
GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
 
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

using LumenWorks.Framework.IO.Csv;

namespace TeachMe.Application.Configuration
{
    public class CsvImportDefaults
    {
        public Property<string> Encoding { get; set; }
        public Property<char> Delimeter { get; set; }
        public Property<char> Escape { get; set; }
        public Property<char> Quote { get; set; }
        public Property<char> Comment { get; set; }
        public Property<ValueTrimmingOptions> Trimming { get; set; }
        public Property<bool> ColumnNamesInFirstRow { get; set; }
        public Property<short> FromIndex { get; set; }
        public Property<short> ToIndex { get; set; }
        public Property<short> ExampleIndex { get; set; }

        public static CsvImportDefaults Create(Checkable parent)
        {
            CsvImportDefaults result = new CsvImportDefaults();
            result.ColumnNamesInFirstRow = new Property<bool>(parent, false);
            result.Comment = new Property<char>(parent, '#');
            result.Delimeter = new Property<char>(parent, ',');
            result.Escape = new Property<char>(parent, '"');
            result.Quote = new Property<char>(parent, '"');
            result.Trimming = new Property<ValueTrimmingOptions>(parent, ValueTrimmingOptions.UnquotedOnly);
            result.FromIndex = new Property<short>(parent, 1);
            result.ToIndex = new Property<short>(parent, 2);
            result.ExampleIndex = new Property<short>(parent, 3);
            result.Encoding = new Property<string>(parent, "Windows-1252");
            return result;
        }
    }
}
